package com.wang.controller;

import com.aaa.entity.OOrder;
import com.aaa.vo.Result;
import com.alipay.api.AlipayApiException;
import com.alipay.api.domain.OdAnalysisLineInfo;
import com.wang.service.OOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;


@RestController
@RequestMapping("/order")
public class OrderConterller {


    @Autowired
    private  OOrderService orderService;


    @GetMapping("/findOrder/{pageCurrent}/{pageSize}")
    public Result findOrder(@PathVariable Integer pageCurrent, @PathVariable Integer pageSize, Integer state){

        System.out.println("++++"+state+"-"+pageSize+"****"+pageSize);
        Result result = orderService.fandAll(pageCurrent, pageSize,state);

        return result;
    }

    @GetMapping("/deleteOrder/{code}")
    public Result deleteOrder(@PathVariable String code){
        Result result = orderService.deleteOrder(code);
        return result;
    }


    @GetMapping("/updete/{id}")
    public Result updete(@PathVariable String id){
        return orderService.updateOrder(id);
    }
    @RequestMapping("/updeteqx/{id}")
    public Result updeteqx(@PathVariable String id){
        return orderService.updateOrderqx(id);
    }
    @RequestMapping("/pay/{paysort}/{code}")
    public Result pay(@PathVariable Integer paysort,@PathVariable String code) throws IOException {
        return orderService.pay(paysort,code);
    }
    @RequestMapping("/paystateus/{code}")
    public Result paystateus(@PathVariable String code) throws AlipayApiException {
        return orderService.paystateus(code);
    }

    @RequestMapping("/paystateuswx/{code}")
    public Result paystateuswx(@PathVariable String code){
        return  orderService.status(code);
    }
    @RequestMapping("/findBycode/{code}")
    public List<OOrder> findBycode(@PathVariable String code){
        List<OOrder>  bycode = orderService.findBycode(code);
        return bycode;
    }
    @RequestMapping("updateSumNum/{residue}/{id}")
    public int updateSumNum(@PathVariable String residue,@PathVariable Integer id){
        return orderService.updateSumNum(residue, id);

    }






}
